It is often beneficial to determine multiple largest or smallest values in an unordered list (or other data set). There are two conventional methods for finding such largest or smallest values. In a first conventional method, the entire unordered list is sorted (from highest to lowest or from lowest to highest). Once the list is sorted, any number of largest values (e.g., the five largest values) or smallest values (e.g., the three smallest values) can be determined. However, sorting an unordered list can be a time consuming process. Moreover, sorting the list modifies the list. To avoid modifying the list, the entire list must be copied, and the copy must then be sorted. Therefore, if it is desirable for the original data (the unsorted list) to remain unchanged, sorting the list requires approximately twice the memory occupied by the original data.
In a second conventional method of determining multiple largest or smallest values in an unordered list, a single smallest or largest value is determined. The value is removed from the unordered list, and the process is repeated to find the new highest or lowest value. This process repeats until a required number of largest or smallest values are determined. The second conventional method requires that the entire unordered list be searched once for each largest or smallest value required. This can be inefficient, and can require considerable time to complete. Moreover, the second conventional method requires that the original data (unordered list) be modified (by deleting a largest or smallest value once it is found). To avoid modifying the unordered list, the list needs to be copied before largest or smallest values are determined. As with the first conventional method, this requires additional memory usage.